package net.monare.mifss.lib;

import org.apache.log4j.Logger;

import java.io.InputStream;
import java.io.Writer;

/**
 * Created by kristan_uros on 9.4.2014.
 */
public class UtilHelper {


    private static Logger logger = Logger.getLogger(UtilHelper.class);

    /**
     * Tries to safely close input stream
     * @param is
     */
    public void closeInputStream(InputStream is) {

        if (is != null) {

            try {
                is.close();
            } catch (Exception e) {
                logger.error("Failed to safely close InputStream.", e);
            }

        }
    }

    /**
     * Tries to safely close output stream
     * @param w
     */
    public void closeOutputStreamWriter(Writer w) {

        if (w != null) {

            try {
                w.close();
            } catch (Exception e) {
                logger.error("Failed to safely close writer.", e);
            }

        }

    }

}
